package com.kkb.staticproxy;

import com.kkb.aop.AOP;
import com.kkb.service.IService;

public class ProxyAOPService implements IService {
    private IService service;
    private AOP aop;

    public ProxyAOPService(IService service, AOP aop) {
        this.service = service;
        this.aop = aop;
    }

    @Override
    public void add(int id, String name) {

    }

    @Override
    public void add() {
        try {
            aop.before();
            service.add();//被代理对象干活
            aop.after();
        } catch (Exception e) {
            e.printStackTrace();
            aop.exception();
        } finally {
            aop.myFinally();
        }
    }

    @Override
    public boolean update(int num) {
        return false;
    }
}
